#ifndef ACFANDRV_H					// Judge the "DisDrv_h" has been defined or not,make sure this file only include once 
#define ACFANDRV_H					// define "MCU_8513_H" 
#ifdef	EXTR				        	//                                                                               
#undef	EXTR                        	// undefine "EXTR"                                                               
#endif
						                                                                                         
#ifdef	ACFANDRV_C			    		// redefine "EXTR",make sure EXTR defined according to the constant of "main".   
#define EXTR    

#define	FAN_TIMER_RATE			(125)               // 时基中断时间  单位us
#define	PLUSE_PER_CYCLE			(3)                // 电机转一圈输出的脉冲数 
#define	CAL_PER_TURN			(2)                 // 转多少圈检测一次转速
#define FAN_FILT_SPEED          (2500)              // 最高滤波转速 单位：转/分钟
#define FAN_MAX_SPEED           (2000)              // 最高转速 单位：转/分钟
#define FAN_MIN_SPEED           (300)               // 最低转速 单位：转/分钟
#define	FAN_DRV_PULSE_WIDTH		(500)				//脉冲宽度单位: us

#define ZERO_DETECC_TYPE       	(0)					//  0:双向过零 	1:单向过零
#define ZERO_DEFAULT_FRE       	(50)              	// 过零默认频率Hz
#define ZERO_MAX_FRE           	(90)              	// 过零最大频率Hz
#define ZERO_MIN_FRE           	(20) 				// 过零最小频率Hz

#define MAX_ADJ_VAL				(400)               // 最大调节度单位:us
#define MIN_PWM_TIM				(800)				// 最小触发时间单位us
#define MAX_PWM_TIM		(u16_zeroCycleTime - 1500)		// 最大触发时间单位us

#define PID_P					3					// P 参数
#define PID_I					24					// I 参数
#define PID_D					1					// D 参数

#define	PutLowFanDrivePin()					{PO_SCR = 0;}
#define	PutHighFanDrivePin()				{PO_SCR = 1;}
#define	SetTimerIntTime(x)					{((TDR03) = (x));}
#define	ClrTimerIntFlag()					{TMIF03 = 0;}	
#define	EnableTimerInt()					{TMMK03 = 0;}
#define	DisableTimerInt()					{TMMK03 = 1;}
#define	StarTimer()							{TS0 |= 0x0008;}
#define	StopTimer()							{TS0 &= ~0x0008;}

#else						                                                                                         
#define EXTR	extern                                                                                               
#endif 




EXTR 	void InFanBckIRQ();
EXTR 	void FanDrv();
EXTR 	void ACFanDriveINT(void);
EXTR 	void ZeroINT(void);

#endif





